<?php

namespace App\Http\Controllers;

use Auth;
use App\Models\Reply;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Requests\ReplyRequest;

class RepliesController extends Controller
{
    public function __construct()
    {
        $this->middleware('auth');
    }



	public function store(ReplyRequest $request, Reply $reply)
	{
		$reply->user_id = Auth::id();
		$reply->topic_id = $request->topic_id;
		$reply->content = $request->content;
		$reply->save();

		return redirect()->route('topics.show', $reply->topic_id)->with('success', '创建成功！.');
	}



	public function destroy(Reply $reply)
	{
		$this->authorize('destroy', $reply);
		$reply->delete();

		return redirect()->route('topics.show', $reply->topic_id)->with('success', '删除成功！');
	}
}